// 测试时间阶段匹配函数
const { getCurrentStageIndex, playList } = require("./2.js");

// 测试用例
const testCases = [
  // 启动与申报阶段
  { date: "2025-10-20", expected: 0, desc: "启动与申报阶段开始" },
  { date: "2025-11-16", expected: 0, desc: "启动与申报阶段结束" },

  // 推荐阶段（优先级高）
  { date: "2025-11-17", expected: 1, desc: "推荐阶段开始" },
  { date: "2025-11-18", expected: 1, desc: "推荐阶段中" },
  { date: "2025-11-23", expected: 1, desc: "推荐阶段结束" },

  // 省级初审（11月下旬，排除推荐阶段）
  { date: "2025-11-24", expected: 2, desc: "省级初审开始" },
  { date: "2025-11-30", expected: 2, desc: "省级初审结束" },

  // 总决赛现场路演
  { date: "2025-12-01", expected: 3, desc: "总决赛开始" },
  { date: "2025-12-05", expected: 3, desc: "总决赛结束" }

  // 颁奖
  { date: "2025-12-06", expected: 4, desc: "颁奖开始" },
  { date: "2025-12-10", expected: 4, desc: "颁奖结束" },

  // 不在任何阶段
  { date: "2025-10-19", expected: -1, desc: "活动开始前" },
  { date: "2025-12-11", expected: -1, desc: "活动结束后" },
];

console.log("=== 时间阶段匹配测试 ===\n");

testCases.forEach((testCase, index) => {
  const result = getCurrentStageIndex(testCase.date);
  const isPass = result === testCase.expected;
  const status = isPass ? "✅ PASS" : "❌ FAIL";

  console.log(`测试 ${index + 1}: ${testCase.desc}`);
  console.log(`  日期: ${testCase.date}`);
  console.log(`  期望索引: ${testCase.expected}`);
  console.log(`  实际索引: ${result}`);
  if (result >= 0) {
    console.log(`  匹配阶段: ${playList[result].name}`);
  }
  console.log(`  结果: ${status}\n`);
});

// 测试当前时间
console.log("=== 当前时间测试 ===");
const currentIndex = getCurrentStageIndex();
console.log(`当前时间: ${new Date().toLocaleDateString("zh-CN")}`);
console.log(`当前阶段索引: ${currentIndex}`);
if (currentIndex >= 0) {
  console.log(`当前阶段: ${playList[currentIndex].name}`);
  console.log(`阶段时间: ${playList[currentIndex].date}`);
} else {
  console.log("当前时间不在任何比赛阶段内");
}
